﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp0
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1login_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "" )
            {
                login();
                
                
            }
            else
            {
                MessageBox.Show("输入不完整,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void login()
        {
            if (radioButtonke.Checked==true)
            {
                string sql = String.Format("select * from Customer where Cid='{0}' and Cpassword='{1}'", textBox1.Text, textBox2.Text); 
                Dao dao= new Dao();
                MessageBox.Show(sql);
                IDataReader dc = dao.read(sql);
                
                string id = textBox1.Text;
                if (dc.Read())
                {
                    MessageBox.Show("登录成功");
                    ke1 ke = new ke1(id);
                    this.Hide();
                    ke.ShowDialog();
                    this.Show();
                }
                else
                {
                    MessageBox.Show("账户编号或密码错误");
                }
            }
            else if (radioButtonshang.Checked == true)
            {
                if (textBox1.Text == "007" && textBox2.Text == "123")  //给定账号和密码
                {
                    MessageBox.Show("登录成功");
                    shang1 shang = new shang1();
                    this.Hide();
                   shang.ShowDialog();
                    this.Show();
                }
                else
                {
                    MessageBox.Show("账户编号或密码错误");
                }
            }
            else
            MessageBox.Show("请选择登录的身份");

        }

        private void button2clear_Click(object sender, EventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }
    }
}
